package edu.whu.rose.clock.kps.algorithm.blinks.search2;

import com.sleepycat.je.DatabaseException;

import edu.whu.rose.clock.kps.algorithm.blinks.index.BilevelIndexDB;
import edu.whu.rose.clock.kps.algorithm.blinks.index.BlockKeyword;
import edu.whu.rose.clock.kps.algorithm.blinks.index.KNEntry;

public class KNCursor2 extends Cursor2 {
	
	public KNCursor2(int block, BilevelIndexDB bidb, String keyword) {
		super(block, bidb);
		BlockKeyword bk = new BlockKeyword(block, keyword);
		try {
			list = bidb.getFromKeywordVertex(bk);
			if (list == null) {
				System.err.println("Error: cannot find KN list for block #" + block + " and keyword: " + keyword);
				System.exit(1);
			}
		}
		catch (DatabaseException ex) {
			ex.printStackTrace();
		}
	}

	public int getFirst() {
		return ((KNEntry)list[pos]).getFirst();
	}

	public int getKnode() {
		return ((KNEntry)list[pos]).getKnode();
	}

	public int getNode() {
		return ((KNEntry)list[pos]).getNode();
	}

	public double getDistance() {
		return ((KNEntry)list[pos]).getDistance();
	}

	public double peek() {
		return ((KNEntry)list[pos + 1]).getDistance();
	}

}
